#include <iostream>
#include <limits>
#include "Merchandise.h"
using namespace std;


void test01()
{
    int i, j;
    cout << "* ";
    for (i = 1; i <= 9; i++)
        cout << i << " ";
    cout << endl;
    for (i = 1; i <= 9; i++)
    {
        cout << i << " ";
        for (j = 1; j <= i; j++)
            cout << i * j << " ";
        cout << endl;
    }
}
void test02() {
    cout << "===== 商品信息测试(test02) =====" << endl;

    // 测试1：基础功能测试
    cout << "\n[测试1] 基本输入输出测试" << endl;
    Merchandise item1;
    cout << "初始状态: " << item1 << endl;  // 应显示空值

    cout << "请输入商品信息(编号 价格 名称): ";
    cin >> item1;
    cout << "输入结果: " << item1 << endl;

    // 测试2：多次输入测试
    cout << "\n[测试2] 多次输入测试" << endl;
    cout << "请再次输入商品信息: ";
    cin >> item1;
    cout << "更新后: " << item1 << endl;

    // 测试3：边界值测试
    cout << "\n[测试3] 边界值测试" << endl;
    Merchandise item2;
    cout << "请输入极大值测试(编号2147483647 价格21474836 名称20字符以上): ";
    cin >> item2;
    cout << "边界测试结果: " << item2 << endl;

    // 测试4：异常输入测试
    cout << "\n[测试4] 异常输入测试" << endl;
    Merchandise item3;
    cin.clear();
    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    cout << "请输入非法数据(如字母代替数字): ";
    cin >> item3;
    if(cin.fail()) {
        cout << "--> 检测到输入错误，已重置商品状态" << endl;
        cin.clear();
        cin.ignore(numeric_limits<streamsize>::max(), '\n');
    }
    cout << "当前状态: " << item3 << endl;

    cout << "\n===== 测试完成 =====" << endl;
}
int main()
{
    test01();
    return 0;
}